#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/6/13 22:21
# @Author  : sailor233
# @File    : read_yaml.py
# @Software: PyCharm
import os

import yaml

from utils.log import logger


def read_yaml(filename, level):
    root_path = os.path.dirname(os.path.dirname(__file__))
    filepath = os.path.join(root_path, 'test_data', filename)
    with open(filepath, 'r', encoding='utf-8') as f:
        data = yaml.safe_load(f)
    test_datas = data.get(level).get('datas')
    ids = data.get(level).get('ids')
    logger.debug(f'读取文件:{filename},读取用例级别:{level}')
    logger.debug(f'{test_datas},{ids}')
    return test_datas, ids


if __name__ == '__main__':
    p0_test_date,p0_ids = read_yaml('add_data.yaml', 'P0')
    print(p0_test_date,p0_ids)